package com.fzg.controller;
import com.fzg.common.enums.ResponseWrapper;
import com.fzg.common.model.user.param.*;
import com.fzg.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author fzg
 * @since 2021-12-13
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 修改密码
     */
    @PostMapping("/editPassword")
    public ResponseWrapper editPassword(@RequestBody @Validated EditPasswordParam param){
        return userService.editPassword(param);
    }

    /**
     * 获取用户列表
     * @param param 参数类
     * @return ResponseWrapper
     */
    @GetMapping("/getUserList")
    public ResponseWrapper getUserList(@Validated GetUserListParam param){
        return userService.getUserList(param);
    }

    /**
     * 删除用户
     */
    @PostMapping("/delUser")
    public ResponseWrapper delUser(Integer aid){
        return userService.delUser(aid);
    }

    /**
     * 编辑用户
     */
    @PostMapping("/editUser")
    public ResponseWrapper editUser(@RequestBody @Validated EditUserParam param){
        return userService.editUser(param);
    }

    /**
     * 新增用户
     */
    @PostMapping("/addUser")
    public ResponseWrapper addUser(@RequestBody @Validated AddUserParam param){
        return userService.addUser(param);
    }

    /**
     * 新增或者删除时判断账号是否存在
     */
    @GetMapping("/checkAcount")
    public ResponseWrapper checkAccount(@Validated CheckAccountParam param){
        return userService.checkAccount(param);
    }

    /**
     * 新增或者删除时判断手机号是否存在
     */
    @GetMapping("/checkPhone")
    public ResponseWrapper checkPhone(@Validated CheckPhoneParam param){
        return userService.checkPhone(param);
    }

    /**
     * 获取除了管理员以外的所有用户
     */
    @GetMapping("/allUser")
    public ResponseWrapper getAllUserExceptAdmin(){
        return userService.getAllUserExceptAdmin();
    }

    /**
     * 获取有求职信息的用户列表
     */
    @GetMapping("/getHaveHuntJobInfoUserAndJobList")
    public ResponseWrapper getHaveHuntJobInfoUserAndJobList(){
        return userService.getHaveHuntJobInfoUserAndJobList();
    }

    /**
     * 将简历url保存到数据库
     */
    @PostMapping("/saveResumeUrl")
    public ResponseWrapper saveResumeUrl(@RequestBody SaveResumeUrl param){
        return userService.saveResumeUrl(param);
    }

}
